home *** CD-ROM | disk | FTP | other *** search
- /*
- * Utility program to format the code resources used with the Daisy
- * printing manager. If you run it twice, it does nothing the second
- * time.
- */
- #include "prglobals.h"
- #define PAD 24L
- typedef struct{
- unsigned int flags;
- unsigned int delay;
- unsigned int emask;
- unsigned int menu;
- }driver,*Pdriver,**Hdriver;
- void mkDefault();
- main()
- {
- setpackflags();
- setdriverflags();
- createPDEF("\psrc:Printer:DaisyPDEF0",0);
- createPDEF("\psrc:Printer:DaisyPDEF4",4);
- createPDEF("\psrc:Printer:DaisyPDEF5",5);
- createPREC();
- }
- /*
- * This is a utility function to strip off the header bytes LightSpeedC
- * puts on Code Resources it creates. I put an illegal instruction right
- * before the code I want.
- */
- createPDEF(filename,idno)
- char *filename;
- int idno;
- {
- long thesize;
- unsigned int **thehandle,**newhandle;
- unsigned int *theword,*newone;
- int thefile;
- int result;
- thefile = OpenResFile(filename);
- thehandle = (unsigned int **) GetResource('pdef',idno);
- if (thehandle == 0L) return;
- else{
- thesize = SizeResource(thehandle) + PAD;
- asm {
- move.l thehandle,a0
- _HLock
- }
- theword = *thehandle;
- while(*theword++ != ILLEGAL){
- thesize -=2;
- }
- asm{
- move.l thesize,d0
- _NewHandle
- move.l a0,newhandle
- }
- if (newhandle == 0L) return;
- else{
- asm{
- move.l newhandle,a0
- _HLock
- move.l (a0),newone
- move.l theword,a0
- move.l newone,a1
- move.l thesize,d0
- _BlockMove
- move.w d0,result
- }
- if(result)return;
- AddResource(newhandle,'PDEF',idno,"\pStripped PDEF");
- WriteResource(newhandle);
- RmveResource(thehandle);
- UpdateResFile(thefile);
- CloseResFile(thefile);
- }
- }
- }
- setdriverflags()
- {
- Hdriver Xprint;
- OpenResFile("\psrc:Printer:DaisyDRVR");
- Xprint = (Hdriver)(GetResource('DRVR',2));
- (*Xprint)->flags = dCtlEnable | dStatEnable;
- (*Xprint)->delay = 0x0000;
- (*Xprint)->emask = 0x0000;
- (*Xprint)->menu = 0x0000;
- ChangedResource(Xprint);
- WriteResource(Xprint);
- }
-
- /*
- * This function sets the version number and flags for the PACK resource
- * used to interface with the Chooser.
- */
- setpackflags()
- {
- long **pack;
- OpenResFile("\psrc:Printer:DaisyPACK");
- pack = (long **)(GetResource('PACK',-4096));
- if (pack != 0L){
- *((*pack)+2) = 0xF0000001;
- *((*pack)+3) = 0x0400E000;
- ChangedResource(pack);
- WriteResource(pack);
- }
- }
- /*
- * Create a default printer settings resource based on the same code used in
- * our printer resource file.
- */
- createPREC()
- {
- THPrint thehandle;
- CreateResFile("\psrc:Printer:DaisyPREC0");
- OpenResFile("\psrc:Printer:DaisyPREC0");
- SetResLoad(TRUE);
- RmveResource(GetResource('PREC',0));
- asm{
- move.l #((long)sizeof(TPrint)),d0
- NewHandle
- move.l a0,thehandle
- }
- mkDefault(thehandle);
- AddResource(thehandle,'PREC',0,"\pPrint defaults");
- WriteResource(thehandle);
- }
- #include "mkDefault.c"
-